//
//  XTCSomeoneSeenU.m
//  ppkc2016
//
//  Created by 拼凑的断音 on 16/4/11.
//  Copyright © 2016年 拼凑的断音. All rights reserved.
//

#import "XTCSomeoneSeenU.h"

#import "XXTool.h"

@interface XTCSomeoneSeenU ()<XVVReleasePersonInfomationDelegate>

@property (nonatomic,strong) UILabel *timeSet;

@property (nonatomic,strong) XVVReleasePersonInfomation *personCard;

@end

@implementation XTCSomeoneSeenU
{
    CGFloat personCardHeight;
}
-(UILabel*)timeSet
{
    if (_timeSet==nil)
    {
        _timeSet = [[UILabel alloc] init];
        _timeSet.font = [XXTool systemFontOfSize:15];
        _timeSet.textColor = [XXTool colorWithHexString:@"C2C2C2"];
        [self addSubview:_timeSet];
    }
    return _timeSet;
}

-(XVVReleasePersonInfomation*)personCard
{
    if (_personCard==nil)
    {
        _personCard = [[XVVReleasePersonInfomation alloc] init];
        _personCard.delegate = self;
        [self addSubview:_personCard];
    }
    return _personCard;
}

-(void)initUI
{
    self.backgroundColor = [XXTool colorWithBackGround];
    [self timeSet];
    [self personCard];
}

-(void)refreshLayout:(CGRect)frame
{
    _timeSet.frame = CGRectMake(18
                                , 10
                                , frame.size.width-18
                                , 17);
    _personCard.frame = CGRectMake(0, _timeSet.frame.size.height+_timeSet.frame.origin.y
                                   , frame.size.width
                                   , personCardHeight);
}

-(void)personInformationDeleteSuccess
{
    if ([_delegate respondsToSelector:@selector(someoneSeenUCellDeleteSuccessWithCell:)])
    {
        [_delegate someoneSeenUCellDeleteSuccessWithCell:self];
    }
}

-(void)setCellWithData:(XMLSeenUModel*)model personType:(XVVReleasePersonInfomationType)useType
{
    [_personCard setData:model personType:useType];
    personCardHeight = [XVVReleasePersonInfomation getHeight:model personType:useType];
    _timeSet.text = [XXTool stampToTimeWithoutYear:model.looktime];
    [self refreshLayout:self.frame];
}

+(CGFloat)getHeight:(XMLSeenUModel*)model personType:(XVVReleasePersonInfomationType)useType
{
    return [XVVReleasePersonInfomation getHeight:model personType:useType]+5+17+10;
}

@end
